# koroFileHeader at Home PC
# Create: 2021-01-01 20:56:33
# LastEdit: 2021-01-01 21:03:49
"""https://leetcode-cn.com/problems/remove-element/"""
__author__ = '749B'

from typing import List

class Solution:
    def removeElement(self, nums: List[int], val: int) -> int:
        shift = 0
        for i in range(len(nums)):
            if nums[i] == val:
                shift += 1
                continue
            if shift:
                nums[i-shift] = nums[i]
        return len(nums) - shift
    